﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UserGUI : MonoBehaviour
{
    private IUserAction action;

    GUIStyle buttonStyle;
    GUIStyle textStyle;

    void Start()
    {
        action = SSDirector.getInstance().currentSceneController as IUserAction;
        
        buttonStyle = new GUIStyle("button");
        buttonStyle.fontSize = 15;
        textStyle = new GUIStyle();
        textStyle.fontSize = 20;
    }

    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            action.Shoot();
        }
        float translationY = Input.GetAxis("Vertical");
        float translationX = Input.GetAxis("Horizontal");
        
        action.MoveBow(translationX, translationY);
    }

    private void OnGUI()
    {
        if (GUI.Button(new Rect(20, 15, 100, 50), "Reset", buttonStyle))
        {
            action.Reset();
        }
        GUI.Label(new Rect(Screen.width - 250, 5, 50, 50), action.GetWind(), textStyle);
        GUI.Label(new Rect(Screen.width - 125, 30, 50, 50), "Score: ", textStyle);
        GUI.Label(new Rect(Screen.width - 50, 30, 50, 50), action.GetScore().ToString(), textStyle);

        GUI.Label(new Rect(Screen.width / 2 - 300, 20, 400, 100), "WASD移动弓，鼠标左键射箭，注意不断变化的风！", textStyle);
    }
}